package data;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;


public class DataQueue {

	Queue<String> queue;
	int receivedItems;
	
	public DataQueue(){
		queue = new ConcurrentLinkedQueue<String>();
		receivedItems = 0;
	}
	
	public synchronized int receivedItems(){
		return receivedItems;
	}
	
	public synchronized boolean add(String s){
		boolean b = queue.add(s);
		if (b) receivedItems++;
		return b;
	}
	
	public synchronized String poll(){
		return queue.poll();  
	}
	
	public synchronized void clear(){
		receivedItems = 0;
		queue.clear();
	}
	
}
